package com.heiye.auth.controller;

import com.heiye.auth.model.dto.user.UserLoginRspDTO;
import com.heiye.auth.service.UserService;
import com.heiye.auth.model.vo.user.UserLoginReqVO;
import com.heiye.framework.common.response.Response;
import com.heiye.framework.biz.operationlog.aspect.ApiOperationLog;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author: heiye
 * @date: 2024/09/23 下午3:29
 * @version: v1.0.0
 * @description: 用户校验接口
 */
@RestController
public class UserController {

    @Resource
    private UserService userService;

    /**
     * 手机号登录校验
     *
     * @param dto
     * @return
     */
    @PostMapping("/login")
    @ApiOperationLog(description = "登录和注册")
    public Response<UserLoginRspDTO> loginAndRegister(@RequestBody UserLoginReqVO dto) {
        return userService.loginAndRegister(dto);
    }


    /**
     * 用户登出
     *
     * @return
     */
    @PostMapping("/logout")
    @ApiOperationLog(description = "用户登出")
    public Response<?> logout() {
        return userService.logout();
    }
}
